package com.caishi.lkx.order.service.impl;

import com.zzw.common.entity.IBaseMapper;
import com.caishi.lkx.order.mapper.PaymentRefundLogMapper;
import com.caishi.lkx.order.model.PaymentModel;
import com.caishi.lkx.order.model.PaymentRefundLogModel;
import com.caishi.lkx.order.service.IPaymentRefundLogService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class PaymentRefundLogServiceImpl implements IPaymentRefundLogService {

    @Resource
    private PaymentRefundLogMapper mapper;

    @Override
    public IBaseMapper<PaymentRefundLogModel, String> getMapper() {
        return mapper;
    }


    @Override
    public PaymentRefundLogModel addLog(PaymentModel paymentModel, long amount) {
        PaymentRefundLogModel model = PaymentRefundLogModel.builder()
                .paymentId(paymentModel.getId().toString())
                .refundAmount(amount)
                .userId(paymentModel.getPayUserId())
                .orderId(paymentModel.getOrderId())
                .refundType(paymentModel.getPaymentType())
                .build();
        return insert(model);
    }
}
